export default {
    name: "Home",
    data() {
        return {
            searchName: "",
            bannerList: [],
            goodList: [],
            queryInto: {
                pagesize: 6,
                pagenum: 1,
            },
            filterData: Object.freeze({
                is_recomend: true,
            }),
            finished: false,
            loading: false,
            error: false,
        };
    },
    created() {
        this.getBanners();
    },
    methods: {
        getBanners() {
            let api = this.$http.api.banner.getList();
            this.$http.callApi(api).then((res) => {
                this.bannerList = res.data || [];
            });
        },
        getGookList() {
            let pagenum = this.queryInto.pagenum;
            let pagesize = this.queryInto.pagesize;
            let api = this.$http.api.good.getPage(pagenum, pagesize);
            this.$http
                .callApi(api, {
                    data: {
                        is_recomend: true,
                    },
                })
                .then((res) => {
                    this.goodList.push(...res.data.good);
                    if (this.goodList.length >= res.data.total) {
                        this.finished = true;
                    } else {
                        this.queryInto.pagenum++;
                    }
                    this.loading = false;
                })
                .catch((err) => {
                    this.loading = false;
                    this.error = true;
                });
        },
    },
};